home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
mmpp010.zip
/
TELEP.CP_
/
TELEP.bin
Wrap
Text File
|
1995-03-30
|
10KB
|
250 lines
// CopyRight Maurizio Maccani 1995
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <direct.h>
#include "trainplb.h"
#include "demo.h"
#include "demo1.h"
#include "csh.h"
long FAR PASCAL _export TestProc(HWND hwnd, UINT message, UINT wParam,
LONG lParam);
// This line is needed to start the STP product
HINSTANCE hInst;
HINSTANCE telLib;
HINSTANCE training;
typedef BOOL * (WINAPI * PLAYBACK) (LPSTR,BOOL,BOOL);
PLAYBACK Pl;
BOOL FAR PASCAL __export TestDialogProc(HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam);
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
MSG msg;
WNDCLASS wndclass;
hInst = hInstance;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW | CS_BYTEALIGNCLIENT | CS_GLOBALCLASS | CS_DBLCLKS;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 4;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, "icon");
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = "menu";
wndclass.lpfnWndProc = TestProc;
wndclass.lpszClassName = "test2";
RegisterClass(&wndclass);
/**********************************************/
/* Remember to load the DLL */
/**********************************************/
telLib = LoadLibrary("telephon.dll");
training = LoadLibrary("training\\stpredis.dll");
Pl = (PLAYBACK) GetProcAddress(training, "Playback");
int ret = SetHelpFile(".\\HELP\\TELEPHON.HLP");
if (ret)
switch (ret) {
case HELP_FILE_DO_NOT_EXISTS:
MessageBox(NULL, "Not existing Help File", "Error", MB_ICONSTOP | MB_OK);
break;
}
SetDefaultHelp(1);
HWND hwndHello = CreateWindow("test2", // window class name
"Test Telephone Library", // window caption
WS_OVERLAPPEDWINDOW, // window style
100, 100, 350, 320,
NULL, // parent window handle
NULL, // window menu handle
(HINSTANCE) hInstance, // program instance
// handle
NULL); // creation parameters
SetWindowHelp(hwndHello, 1);
ShowWindow(hwndHello, SW_SHOW);
UpdateWindow(hwndHello);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
FreeLibrary(telLib);
FreeLibrary(training);
return msg.wParam;
}
long FAR PASCAL _export TestProc(HWND hwnd, UINT message, UINT wParam,
LONG lParam)
{
switch (message) {
case END_PLAYBACK_MESS:
PostQuitMessage(0);
return 0;
case WM_CREATE:
{
int i = 54;
HWND telNumber = CreateWindow("Telephone", "3336788", WS_CHILD | WS_VISIBLE, 120, 20, 200, 95, hwnd, 1, hInst, &i);
SetWindowHelp(telNumber, 0x0052);
HWND telNumber1 = CreateWindow("Telephone", "", WS_CHILD | WS_VISIBLE, 120, 50, 200, 125, hwnd, 1, hInst, NULL);
SetWindowHelp(telNumber1, 0x0053);
HWND NumberS = CreateWindow("Static", "Filled", WS_CHILD | WS_VISIBLE, 10, 20, 100, 25, hwnd, 1, hInst, NULL);
HWND ZeroNumberS = CreateWindow("Static", "Empty", WS_CHILD | WS_VISIBLE, 10, 50, 100, 25, hwnd, 1, hInst, NULL);
HWND NumberS2 = CreateWindow("Static", "Other Font", WS_CHILD | WS_VISIBLE, 10, 80, 100, 25, hwnd, 1, hInst, NULL);
HWND telNumber2 = CreateWindow("Telephone", "", WS_CHILD | WS_VISIBLE, 120, 80, 200, 125, hwnd, 1, hInst, NULL);
SetWindowHelp(telNumber1, 0x0054);
LOGFONT FAR *plf = (LOGFONT FAR *) GlobalAllocPtr(GMEM_ZEROINIT, sizeof(LOGFONT));
HDC hdc = GetWindowDC(hwnd);
int Yinch = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(hwnd, hdc);
plf->lfHeight = -((16 * Yinch) / 72);
plf->lfWeight = FW_NORMAL;
lstrcpy(plf->lfFaceName, "Times New Roman");
HFONT nFont = CreateFontIndirect(plf);
SendMessage(telNumber2, WM_SETFONT, nFont, MAKELONG(TRUE, 0));
GlobalFreePtr(plf);
SetWindowLong(hwnd, 0, nFont);
SetMenuHelp(hwnd, EXIT, 0x0041);
SetMenuHelp(hwnd, DIALOG_STRING, 0x0042);
SetMenuHelp(hwnd, INTRODUCTION_TRAINING, 0x0043);
SetMenuHelp(hwnd, MODEM_TRAINING, 0x0044);
SetMenuHelp(hwnd, DATA_BASE_TRAINING, 0x0045);
SetMenuHelp(hwnd, PORTABLE_TRAINING, 0x0046);
SetMenuHelp(hwnd, INTRODUCTION_HELP, 0x0047);
SetMenuHelp(hwnd, MODEM_HELP, 0x0047);
SetMenuHelp(hwnd, DATA_BASE_HELP, 0x0047);
SetMenuHelp(hwnd, PORTABLE_HELP, 0x0047);
SetMenuHelp(hwnd, ORDER_HELP, 0x0047);
SetMenuHelp(hwnd, ABOUT, 0x0048);
}
return 0;
case WM_DESTROY:
DeleteObject((HFONT) GetWindowLong(hwnd, 0));
PostQuitMessage(0);
return 0;
case WM_COMMAND:
{
switch (wParam) {
case EXIT:
DestroyWindow(hwnd);
PostQuitMessage(0);
return 0;
case DIALOG_STRING:
{
DLGPROC testDialogProc;
testDialogProc = (DLGPROC) MakeProcInstance((FARPROC) TestDialogProc, hInst);
int Test = DialogBox(hInst, "DialogTest", hwnd, testDialogProc);
FreeProcInstance(testDialogProc);
return 0;
}
case MODEM_HELP:
chdir(".\\help");
WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0007);
chdir("..");
break;
case ORDER_HELP:
WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0013);
break;
case DATA_BASE_HELP:
WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0003);
break;
case PORTABLE_HELP:
WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0005);
break;
case INTRODUCTION_HELP:
WinHelp(hwnd, "help\\telephon.hlp", HELP_CONTEXT, 0X0001);
break;
case INTRODUCTION_TRAINING:
{
if (Pl)
Pl("training\\Intro.tra",FALSE,FALSE);
break;
}
case MODEM_TRAINING:
{
if (Pl)
Pl("training\\Modem.tra",FALSE,FALSE);
break;
}
break;
case DATA_BASE_TRAINING:
{
if (Pl)
Pl("training\\DB.tra",FALSE,FALSE);
break;
}
break;
case PORTABLE_TRAINING:
{
if (Pl)
Pl("training\\Portable.tra",FALSE,FALSE);
break;
}
break;
case ABOUT:
{
MessageBox(NULL, "Telephone Control \012 Copyright Maurizio Maccani 1995", "About", MB_OK);
return 0;
}
}
}
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
BOOL FAR PASCAL __export TestDialogProc(HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
typedef void (FAR PASCAL * INTCODE) (HWND, int);
INTCODE SetDefaultIntCode;
SetDefaultIntCode = (INTCODE) GetProcAddress(telLib, "SetDefaultIntCode");
if (SetDefaultIntCode)
SetDefaultIntCode(GetDlgItem(hDlg, IDC_EDIT1), 55);
SetFocus(GetDlgItem(hDlg, IDC_EDIT1));
SetWindowHelp(GetDlgItem(hDlg, IDC_EDIT1), 0x0049);
SetWindowHelp(GetDlgItem(hDlg, IDC_EDIT2), 0x0050);
SetWindowHelp(hDlg, 0x0051);
return 0;
case WM_CLOSE:
EndDialog(hDlg, 0);
return TRUE;
case WM_COMMAND:
switch (wParam) {
case IDOK:
EndDialog(hDlg, 0);
return TRUE;
default:
break;
}
break;
}
return (FALSE);
} // end of TestDialogProc()
BOOL FAR PASCAL __export SharewareDialogProc(HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_CLOSE:
EndDialog(hDlg, 0);
return TRUE;
case WM_COMMAND:
switch (wParam) {
case IDOK:
EndDialog(hDlg, 0);
return TRUE;
}
break;
}
return (FALSE);
} // end of TestDialogProc()